<template>
  <el-container class="allbody" onscroll="false">
  

    <el-main style="height: 100%; z-index: 5">
      <!--<Calendar-->
      <!--v-on:choseDay="clickDay"-->
      <!--v-on:changeMonth="changeDate"-->
      <!--&gt;</Calendar>-->
      <el-row style="width: 100%; height: 10%">
        <el-form
          :inline="true"
          class="demo-form-inline"
          style="margin-top: 20px; margin-left: 10px"
          :model="postForm"
          ref="postForm"
        >
          <el-form-item>
            <el-input
              v-model="Equ"
              class="form-input"
              style="width: 250px"
              disabled
            ></el-input>
          </el-form-item>

          <el-form-item>
            <el-input
              v-model="Sydw"
              class="form-input"
              style="width: 300px"
              disabled
            ></el-input>
          </el-form-item>
          <el-select v-model="timeValue" @change="selectDate">
            <el-option
              v-for="item in timeOption"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>

          <!-- <el-form-item>
            <el-button style="color: #009bfe" @click="show">查询</el-button>
          </el-form-item> -->
          <el-form-item style="position: absolute; right: 120px">
            <i class="el-icon-back" style="color: black; font-size: 25px"></i>
            <el-button
              type="text"
              style="color: black; font-size: 22px"
              @click="switchList"
              >返回上一级</el-button
            >
          </el-form-item>
        </el-form>
      </el-row>

      <el-row style="width: 100%; height: 90%">
        <el-table
          :data="tableData"
          style="width: 100%; height: 100%"
          fit="true"
          height="800"
        >
          <el-table-column prop="one" label="序号" width="270">
          </el-table-column>
          <el-table-column prop="two" label="点检部位" width="635">
          </el-table-column>
          <el-table-column prop="three" label="点检内容" width="635">
          </el-table-column>

          <el-table-column prop="workTemperature" label="点检实绩" width="270">
          </el-table-column>
        </el-table>
      </el-row>
    </el-main>
  </el-container>
</template>

<script>
import ElContainer from "element-ui/packages/container/src/main";
import ElAside from "element-ui/packages/aside/src/main";
import ElHeader from "element-ui/packages/header/src/main";
import ElMain from "element-ui/packages/main/src/main";

import { get, get as userType, del, dels } from "@/api/sys/connSysAuthApi";
import { parseTime } from "@/utils";
import { req } from "@/api/base/BaseApi";

import Calendar from "vue-calendar-component";
const defaultForm = {
  year: undefined,
  month: undefined,
  day: undefined,
  f002: undefined,
};
export default {
  name: "index",
  components: { Calendar },
  comments: {
    ElMain,
    ElHeader,
    ElAside,
    ElContainer,
  },
  methods: {
    dateFormat(time) {
      var date = new Date(time);
      var year = date.getFullYear();
      /* 在日期格式中，月份是从0开始的，因此要加0
       * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
       * */
      var month =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
      var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
      var hours =
        date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
      var minutes =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
      var seconds =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      // 拼接
      return (
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hours +
        ":" +
        minutes +
        ":" +
        seconds
      );
    },
    tableRowStyle({ row, rowIndex }) {
      return "background-color: #02152f;color: #fff";
    },
    tableHeaderColor({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return "background-color: #2ec7c9;color: #fff;font-weight: 500;";
      }
    },
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type];
    },
    getRowClass({ row, column, rowIndex, columnIndex }) {
      console.log("调用行样式");
      return {
        background: "#06134A",
        color: "#72C22D",
      };
    },
    getTableDataFormSon(data) {
      const tableDataTemp = data;
      this.tableData = [];
      for (let j = 9; j >= 0; j--) {
        const tableDataI = {};
        for (let i = 0; i < this.measurePoints.length; i++) {
          const point = this.measurePoints[i];
          const values = tableDataTemp.get(point);
          const date = new Date(values[j].name);
          if (i <= 0) {
            tableDataI["time"] =
              date.getFullYear() +
              "/" +
              (date.getMonth() + 1) +
              "/" +
              date.getDate() +
              " " +
              date.getHours() +
              ":" +
              date.getMinutes() +
              ":" +
              date.getSeconds();
          }
          tableDataI[point + "value"] = values[j].value;
        }
        this.tableData.push(tableDataI);
      }
      this.currTableData = [];
      for (let i = 0; i < this.measurePoints.length; i++) {
        const point = this.measurePoints[i];
        const values = tableDataTemp.get(point);
        const date = new Date(values[values.length - 1].name);
        this.currTableData.push({
          point: point,
          data: values[values.length - 1].value,
          time:
            date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(),
        });
      }
    },
    switchList() {
      this.$emit("switchList");
    },
    show() {
      //显示所有工艺流程信息
      this.postForm.f002 = this.timeValue;
      console.log(this.postForm);
      req("/lifting-service/mgpointcheck", "GET", this.postForm)
        .then((response) => {
          var i = 0;
          var str = "";
          for (i; i < 56; i++) {
            if (i < 7) {
              str = "f00";
            } else {
              str = "f0";
            }
            str += i + 3;
            this.tableData[i].workTemperature = response.data[0][str];

          }
           this.$message({
              message: "获取点检数据成功",
              type: "success",
            });
        })
        .catch(() => console.log("page request error"));
    },
    yearChange(id, type) {
      this.postForm.year = id;
    },
    monthChange(id, type) {
      this.postForm.month = id;
    },
    dayChange(id, type) {
      this.postForm.day = id;
    },

    // 获取点检报告的时间列表
    async searchDateList() {
      const { data } = await req(
        "/lifting-service/mgpointcheck/allListPage",
        "GET"
      );
      // 处理时间格式
      this.timeOption = data.map((item) => {
        const timeStr = item.f002.split("-").join("/");
        return {
          label: timeStr,
          value: timeStr,
        };
      });
      // 默认选择第一个时间
      this.timeValue = this.timeOption[0].value;
      this.selectDate();
    },

    // 选择某个日期
    selectDate() {
      this.show();
    },
  },
  async created() {
    req("/lifting-service/mgpointcheckindex/allList", "GET", "")
      .then((response) => {
        var i = 0;
        for (i; i < 56; i++) {
          this.tableData[i].one = response.data[i].id;
          this.tableData[i].two = response.data[i].part;
          this.tableData[i].three = response.data[i].partcontent;
        }
      })
      .catch(() => console.log("page request error"));
    // 获取所有的点检日期
    await this.searchDateList();
  },
  computed: {
    Equ() {
      return "设备编号：" + this.EquValue;
    },
    Sydw() {
      return "使用单位：" + this.SydwValue;
    },
  },
  data() {
    return {
      postForm: Object.assign({}, defaultForm),
      date: new Date(),
      year: "",
      month: "",
      day: "",
      mydate: "",
      EquValue: "一钢轧 008",
      SydwValue: "马鞍山钢铁股份有限公司",
      timeOption: [], // 点检报告的时间列表。一份点检报告一个时间
      timeValue: "", // 当前选中的点检报告时间、
      detailData: "", // 当前显示的点检报告数据

      // -------------------------------------------------------------------------
      options1: [
        {
          value: "2018",
          label: "2018",
        },
        {
          value: "2019",
          label: "2019",
        },
        {
          value: "2020",
          label: "2020",
        },
      ],
      location: "",
      options2: [
        {
          value: "1",
          label: "1",
        },
        {
          value: "2",
          label: "2",
        },
        {
          value: "3",
          label: "3",
        },
        {
          value: "4",
          label: "4",
        },
        {
          value: "5",
          label: "5",
        },
        {
          value: "6",
          label: "6",
        },
        {
          value: "7",
          label: "7",
        },
        {
          value: "8",
          label: "8",
        },
        {
          value: "9",
          label: "9",
        },
        {
          value: "10",
          label: "10",
        },
        {
          value: "11",
          label: "11",
        },
        {
          value: "12",
          label: "12",
        },
      ],
      city: "",
      options: [
        {
          value: "1",
          label: "1",
        },
        {
          value: "2",
          label: "2",
        },
        {
          value: "3",
          label: "3",
        },
        {
          value: "4",
          label: "4",
        },
        {
          value: "5",
          label: "5",
        },
        {
          value: "6",
          label: "6",
        },
        {
          value: "7",
          label: "7",
        },
        {
          value: "8",
          label: "8",
        },
        {
          value: "9",
          label: "9",
        },
        {
          value: "10",
          label: "10",
        },
        {
          value: "11",
          label: "11",
        },
        {
          value: "12",
          label: "12",
        },
        {
          value: "13",
          label: "13",
        },
        {
          value: "14",
          label: "14",
        },
        {
          value: "15",
          label: "15",
        },
        {
          value: "16",
          label: "16",
        },
        {
          value: "17",
          label: "17",
        },
        {
          value: "18",
          label: "18",
        },
        {
          value: "19",
          label: "19",
        },
        {
          value: "20",
          label: "20",
        },
        {
          value: "21",
          label: "21",
        },
        {
          value: "22",
          label: "22",
        },
        {
          value: "23",
          label: "23",
        },
        {
          value: "24",
          label: "24",
        },
        {
          value: "25",
          label: "25",
        },
        {
          value: "26",
          label: "26",
        },
        {
          value: "27",
          label: "27",
        },
        {
          value: "28",
          label: "28",
        },
        {
          value: "29",
          label: "29",
        },
        {
          value: "30",
          label: "30",
        },
        {
          value: "31",
          label: "31",
        },
      ],
      calendar: {},
      tableData: [
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
        {
          one: "",
          two: "",
          three: "",
          workTemperature: "",
        },
      ],
    };
  },
  filters: {
    userTypeFilter(type) {
      let typeText = type;
      userTypes.forEach((val) => {
        if (type === val.value) {
          typeText = val.name;
        }
      });
      return typeText;
    },
    menuFilter(ids) {
      let length = 0;
      if (ids) {
        length = ids.length;
      }
      return length;
    },
    dateTimeFilter(time) {
      return parseTime(time);
    },
  },
  mounted() {
    let _this = this; //声明一个变量指向vue实例this,保证作用域一致
    this.timer = setInterval(function () {
      _this.date = new Date(); //修改数据date
    }, 1000);
    this.postForm = Object.assign({}, defaultForm);
  },
};
</script>

<style lang="less" scoped>
.headerbackgroud {
}
.allbody {
  width: 100%;
  height: 1050px;
}
.rowclass {
  width: 100%;
  height: 50%;
}

#text {
  -webkit-text-fill-color: white;
}
.select {
  color: white;
}
.hello {
  // 未选中任何选项的时候 placeholder的样式 需要先选中父元素 增加权重
  /deep/ input::-webkit-input-placeholder {
    color: #fff;
  }
  /deep/ input::-moz-input-placeholder {
    color: #fff;
  }
  /deep/ input::-ms-input-placeholder {
    color: #fff;
  }

  //修改的是el-input的样式
  //一种方法是设置最里层el-input__inner的背景色 外层的两级父元素设置为透明色
  //另一种方法是从el-select到el-input__inenr的背景色都设置为需要的颜色
  /deep/ .el-select,
  /deep/ .el-input,
  /deep/ .el-input__inner {
    background-color: #08164d;
    color: #fff;
    border: 0px;
    border-radius: 0px;
    text-align: center;
  }
}
.form-input /deep/ .el-input__inner {
  color: rgb(0, 0, 0) !important;
}
.map1,
.map2,
.map3 {
  position: absolute;
  opacity: 0.5;
}
.map1 {
  margin-left: 580px;
  margin-top: 230px;
  z-index: 2;
  animation: myfirst2 15s infinite linear;
}
.map2 {
  margin-left: 625px;
  margin-top: 275px;
  z-index: 3;
  opacity: 0.2;
  animation: myfirst 10s infinite linear;
}
.map3 {
  margin-left: 650px;
  margin-top: 300px;
  z-index: 1;
}
@keyframes myfirst2 {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(359deg);
  }
}

@keyframes myfirst {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-359deg);
  }
}
</style>
